<!DOCTYPE html>
<html>
<head lang="zh-CN">
    <title>登录</title>
    <meta charset="UTF-8">
	<meta name="keywords" content="">
	<meta name="description" id="description" content="">
	<meta name="viewport" content="width=device-width,user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1"/>
	<meta name="format-detection" content="telephone=no, email=no"/>
	<meta name="apple-touch-fullscreen" content="yes">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta http-equiv="Expires" content="-1">
	<meta http-equiv="pragram" content="no-cache">
	<!--css-->
	<link rel="stylesheet" href="css/vant.css"/>
	<link rel="stylesheet" href="css/common.css"/>
	<link rel="stylesheet" href="css/style.css"/>
	<!--js-->
	<script src="js/jquery.min.js"></script>
	<script src="js/md5.min.js"></script>
	<script src="js/flexible.js"></script>
	<script src="js/vue.min.js"></script>
	<script src="js/vant.min.js"></script>
	<script src="js/verify.js"></script>
	<script src="js/wxtool.js?v=4"></script>
</head>
<body>
<!--http://zp-www.t.hnic.com.cn/phoneBindWechat/-->
	<div class="wrap Index" id="app">
	    <div class="container">
			<div class="logo"><img src="images/logo.png" alt=""></div>
			<div style="height: auto;overflow:hidden;">
				<div class="title" style="margin-bottom: .4rem;padding-bottom: .25rem;border-bottom: 1px solid #eee">黄河人才网申请使用微信登录</div>
				<div class="" style="float: left"><img class="headimgurl" src="https://res.huanghehr.com/default/jl.jpg"   width="50px"></div>
				<div class="title" style="float: left;padding-left: .2rem; ">
					<h2 style="color:#333"> {{wxUser.nickname}}</h2>
					<p style="font-size: .24rem;color:#999;margin-top: .05rem">微信个人信息</p>
				</div>
			 </div>
<!--			<div class="dsc">绑定微信公众号，随时获取应聘进度微信通知</div>-->
			<div class="form" style="clear: both;margin-top: .4rem;">
				 <div class="btn"  @click="confirm('ok')">同意</div>
<!--				 <div class="btn" style="background-color: gray" @click="confirm('refuse')">拒绝</div>-->
			</div>
		</div><!--container-->
	</div><!--wrap-->

	<div class="guanzhuBox" style="width: 100%;height: 100%;position: fixed;left:0;top: 0;z-index: 99;background: rgba(0,0,0,.7)">
		<img src="https://www.huanghehr.com/assets/img/qr.jpg" style="width: 3rem;display: block;margin: 30vh auto .2rem">
		<p style="font-size: .3rem;color: #fff;text-align: center;">长按识别二维码关注</p>
	</div>
	<script>
        var basePath = '/prod-api/'
		if(window.location.host.indexOf('127.0.0.1')>=0||window.location.host.indexOf('192.168.')>=0||window.location.host.indexOf('localhost')>=0){
			basePath = 'http://zp-www.t.hnic.com.cn/prod-api/'
			basePath = 'http://127.0.0.1:7777'
			console.log('当前属于测试模式'+'=>>>>>>>>>>>>>>>>>>>>>basePath>>>>'+basePath);


		}
        var app = new Vue({
            el: '#app',
            data: {
				phone:'',//手机号
				code:'',//验证码
				verifyFlag:false,//验证标识
                codeName:'获取验证码',
				disabledFlag: false,//获取验证码能否点击
				time: 60,

				wxUser:{
					"authflag": "1",
						"city": "郑州",
						"country": "中国",
						"groupid": 0,
						"headimgurl": "",
						"language": "zh_CN",
						"latitude": 0,
						"longitude": 0,
						"nickname": "测试",
						"openid": "",//关键信息
						"precision": 0,
						"privilege": [],
						"province": "河南",
						"remark": "",
						"remarkname": "",
						"sex": 1,
						"subscribe": 1,
						"subscribeTime": "2017-06-28 18:26:24",
						"subscribe_time": 1498645584,
						"tagid_list": [],
						"unionid": ""//关键信息
				},


            },
            //方法
            methods: {

				getUrlParam(name,url) {
					url=url.substring(url.indexOf("?")+1,url.length);
					//alert(url);
					for(var i=0;i<url.split("&").length;i++){
						var p=url.split("&")[i].replace("#","");
						var n=p.split("=")[0];
						var v=p.split("=")[1];
						// alert(name+"="+v);
						//if(n==name) return v;
						if(n==name) return decodeURIComponent(v);

					}
					return '';
				},
						//绑定用户
				confirm(operType){
					let token=this.getUrlParam("token",window.location.href)
					if(''==token){
						vant.Toast('请扫描登录二维码');
						return false;
					}
					let that=this;
					console.log(operType,token,that.wxUser.nickname,that.wxUser.unionid,that.wxUser.openid)

					$.ajax({
						type:"POST",
						contentType:'application/json;charset=utf-8',
						dataType:"json",
						url:basePath + "personal/wxLogin/h5/confirm?r="+Math.random(),
						data:JSON.stringify({
							"operType":operType,
							"token":token,
							"nickname":that.wxUser.nickname,
							"thirdType":'wx.oa',
							"unionid":that.wxUser.unionid,
							"openid":that.wxUser.openid
						}),
						success:function(res){
							console.log(res)
							if(res.code==200){
							  // vant.Toast('绑定成功， 您可以通过公众号收到消息提醒了');
								window.location.replace("success.html")
							}else if('604'==res.code){
								vant.Toast('授权成功，请先绑定');
								window.location.replace("success.html?UN_BIND")
							} else{
								vant.Toast(res.message);
							}
						}
					});
				},
			},

            //生命周期 - 创建完成（可以访问当前this实例）
            created() {
				_wxtool.auth2()
				this.wxUser=_wxtool.getUser();
				console.log(this.wxUser.nickname)
				if(1==this.wxUser.subscribe){
					$(".guanzhuBox").hide();
				}
				$(".headimgurl").attr("src",this.wxUser.headimgurl);
				//
				// headimgurl
            },
            //生命周期 - 挂载完成（可以访问DOM元素）
            mounted() {

				var that = this
                var SlideVerifyPlug = window.slideVerifyPlug;
				var slideVerify = new SlideVerifyPlug('#verify-wrap',{
					wrapWidth:'',//设置 容器的宽度 ,不设置的话，会设置成100%，需要自己在外层包层div,设置宽度，这是为了适应方便点；
					initText:'请向右滑动滑块',  //设置  初始的 显示文字
					sucessText:'验证通过',//设置 验证通过 显示的文字
					getSuccessState:function(res){
						//当验证完成的时候 会 返回 res 值 true，只留了这个应该够用了
						that.verifyFlag = res
						console.log('verifyFlag= ' + that.verifyFlag)
					}
				});
            }
        })
    </script>
</body>
</html>
